
import { Component, OnInit } from '@angular/core';
import { MerchantcashrecordService } from '../../service/merchantcashrecord.service';
import { MerchantinfoService } from '../../service/merchantinfo.service';
import { MerchantwineService } from '../../service/merchantwine.service';
import { NzMessageService } from 'ng-zorro-antd';
import { CommonService } from 'src/app/service/common.service';
import { ComponentBasic } from '../../app.component';
import { RoleRight } from '../../../kalend';
@Component({
  selector: 'app-merchantinfo',
  templateUrl: './agentmerchantwinemanage.component.html',
  styleUrls: ['./agentmerchantwinemanage.component.scss'],
  providers: [MerchantcashrecordService, CommonService, MerchantinfoService, MerchantwineService]
})
export class AgentmerchantwinemanageComponent extends ComponentBasic implements OnInit {
  loading = true;
  pageIndex = 1;
  winelist = [];
  pageSize = 15;
  total = 1;
  doc: any = {};
  dataSet = [];
  sdate: any;
  edate: any;
  iscontact: any;
  remarks: any;
  auditstatus: any;
  sendstatus: any;
  name: any;
  //提现金额
  cashmoney: any;
  isVisible = false;
  isCrshVisible = false;
  isOkLoading = false;
  LoginUser = RoleRight.getStorage();
  statuslist = [{ key: 0, value: '未审核' }, { key: 1, value: '已审核' }, { key: 2, value: '审核拒绝' }];
  statuslist2 = [{ key: 0, value: '未配送' }, { key: 1, value: '已配送' }];
  constructor(private merchantwine: MerchantwineService, private merchantinfoService: MerchantinfoService, private merchantcashrecord: MerchantcashrecordService, private msg: NzMessageService, private commonservice: CommonService) {
    super();
    super.setLayout(true, true);
  }

  ngOnInit() {

    this.searchData();
  }
  searchData(reset: boolean = false): void {
    this.loading = true;
    this.merchantwine.querymerchantapplywinebypage({
      offset: this.pageIndex,
      limit: this.pageSize,
      agentid: this.LoginUser._id,
      auditstatus: this.auditstatus,
      sendstatus: this.sendstatus,
      name: this.name,
      sdate: this.sdate,
      edate: this.edate

    }).then((res) => {
      this.loading = false;
      this.total = res.total;
      this.dataSet = res.rows;
    });
  }
  auditpass(id): void {
    this.merchantwine.auditmappwinestatus({
      _id: id,
      AuditStatus: 1
    }).then((r) => {
      this.searchData();
    });;

  }
  auditrefuse(id): void {
    this.merchantwine.auditmappwinestatus({
      _id: id,
      AuditStatus: 0
    }).then((r) => {
      this.searchData();
    });
  }
  Sendpass(id): void {
    this.merchantwine.auditmappwinestatus({
      _id: id,
      SendStatus: 1
    }).then((r) => {
      this.searchData();
    });;
  }
  //查看详情
  see(id): void {
    this.isVisible = true;
    let oneapply = this.merchantwine.queryonewineapply({ id: id }).then((res) => {
      this.winelist = res.winelist;
    });;

  }

  //确定提交
  handleOk(): void {
    // let parm={
    //   totalcase:this.cashmoney,
    //   BankCardNo:this.doc.BankCardNumber,
    //   merchantid:this.doc._id,
    //   Bank:this.doc.Bank
    // }
    //   this.merchantcashrecord.create(parm).then((res) => {
    //     this.searchData();
    //     this.isVisible = false;
    //     this.doc = {};
    //   });
    this.isVisible = false;
    this.doc = {};
  }

  handleCancel(): void {
    this.isVisible = false;
    this.doc = {};
  }
}
